import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'

import Main from '../components/Main.vue'
// import File2 from '../components/File2.vue'

const routes = [
    {
        path: '/',
        component: Main
    }
]

const router = createRouter({
    // history: createWebHistory(),
    history: createWebHistory(import.meta.env.BASE_URL),
    // history:createWebHashHistory(),
    routes
})
//全局路由守卫

router.beforeEach((to, from, next) => {
    if (!to.fullPath.includes("token")) {
        // next({ path: 'https://www.cxyth.com/login' });
        window.location.href = "https://www.cxyth.com/login";
    } else {
        next();
    }
});

export default router
